home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / GNU / GNUPLOTsrc.lha / term / fg.trm < prev    next >
Encoding:
Text File  |  1996-01-22  |  9.5 KB  |  400 lines

  1. /* GNUPLOT - fg.trm */
  2. /*
  3.  * Copyright (C) 1990, 1991, 1992
  4.  *
  5.  * Permission to use, copy, and distribute this software and its
  6.  * documentation for any purpose with or without fee is hereby granted, 
  7.  * provided that the above copyright notice appear in all copies and 
  8.  * that both that copyright notice and this permission notice appear 
  9.  * in supporting documentation.
  10.  *
  11.  * Permission to modify the software is granted, but not the right to
  12.  * distribute the modified code.  Modifications are to be distributed 
  13.  * as patches to released version.
  14.  *
  15.  * This software  is provided "as is" without express or implied warranty.
  16.  *
  17.  * This file is included by ../term.c.
  18.  *
  19.  * This terminal driver supports:
  20.  *    Under Zortech C
  21.  *      egalib, vgalib, vgamono, svga, mcga, cga, hercules, att
  22.  *
  23.  * AUTHORS
  24.  *          Gnuplot for DOS 386/flash graphics
  25.  *                  Clifton T. Liu
  26.  *
  27.  * There is a mailing list for gnuplot users. Note, however, that the
  28.  * newsgroup 
  29.  *    comp.graphics.gnuplot 
  30.  * is identical to the mailing list (they
  31.  * both carry the same set of messages). We prefer that you read the
  32.  * messages through that newsgroup, to subscribing to the mailing list.
  33.  * (If you can read that newsgroup, and are already on the mailing list,
  34.  * please send a message info-gnuplot-request@dartmouth.edu, asking to be
  35.  * removed from the mailing list.)
  36.  *
  37.  * The address for mailing to list members is
  38.  *       info-gnuplot@dartmouth.edu
  39.  * and for mailing administrative requests is 
  40.  *       info-gnuplot-request@dartmouth.edu
  41.  * The mailing list for bug reports is 
  42.  *       bug-gnuplot@dartmouth.edu
  43.  * The list of those interested in beta-test versions is
  44.  *       info-gnuplot-beta@dartmouth.edu
  45.  */
  46. /* The modifications to allow Gnuplot to compile with Zortech C/C++   */
  47. /* 3.1 /Flash Graphics    were made by Clifton T. Liu                   */
  48. /* (cliu@merlin.appmath.columbia.edu)         20 Feb 1993              */
  49.  
  50. /*
  51.  * adapted to the new terminal layout by Stefan Bodewig (Dec. 1995)
  52.  */
  53.  
  54. #ifndef GOT_DRIVER_H
  55. #include "driver.h"
  56. #endif
  57.  
  58. #ifdef TERM_REGISTER
  59. register_term(hercules)
  60. register_term(egamono)
  61. register_term(egalib)
  62. register_term(vgalib)
  63. register_term(vgamono)
  64. register_term(svgalib)
  65. register_term(ssvgalib)
  66. #endif
  67.  
  68. #ifdef TERM_PROTO
  69. TERM_PUBLIC void PC_text __P((void));
  70. TERM_PUBLIC void PC_reset __P((void));
  71. TERM_PUBLIC int VGA_text_angle __P((int ang));
  72. TERM_PUBLIC int VGA_justify_text __P((enum JUSTIFY mode));
  73. TERM_PUBLIC void VGA_init __P((void));
  74. TERM_PUBLIC void HERC_graphics __P((void));
  75. TERM_PUBLIC void EGAMONO_graphics __P((void));
  76. TERM_PUBLIC void EGA_graphics __P((void));
  77. TERM_PUBLIC void VGA_graphics __P((void));
  78. TERM_PUBLIC void VGAMONO_graphics __P((void));
  79. TERM_PUBLIC void SVGA_graphics __P((void));
  80. TERM_PUBLIC void SSVGA_graphics __P((void));
  81. TERM_PUBLIC void VGA_linetype __P((int linetype));
  82. #define HERC_XMAX 720
  83. #define HERC_YMAX 348
  84.  
  85. #define HERC_XLAST (HERC_XMAX - 1)
  86. #define HERC_YLAST (HERC_YMAX - 1)
  87.  
  88. #define HERC_VCHAR 10
  89. #define HERC_HCHAR 8
  90. #define HERC_VTIC 5
  91. #define HERC_HTIC 5
  92.  
  93.  
  94.  
  95. #define EGA_XMAX 640
  96. #define EGA_YMAX 350
  97.  
  98. #define EGA_XLAST (EGA_XMAX - 1)
  99. #define EGA_YLAST (EGA_YMAX - 1)
  100.  
  101. #define EGA_VCHAR 18
  102. #define EGA_HCHAR 8
  103. #define EGA_VTIC 5
  104. #define EGA_HTIC 5
  105.  
  106.  
  107. #define VGA_XMAX 640
  108. #define VGA_YMAX 480
  109.  
  110. #define VGA_XLAST (VGA_XMAX - 1)
  111. #define VGA_YLAST (VGA_YMAX - 1)
  112.  
  113. #define VGA_VCHAR 24
  114. #define VGA_HCHAR 8
  115. #define VGA_VTIC 5
  116. #define VGA_HTIC 5
  117.  
  118.  
  119. #define SVGA_XMAX 800
  120. #define SVGA_YMAX 600
  121.  
  122. #define SVGA_XLAST (SVGA_XMAX - 1)
  123. #define SVGA_YLAST (SVGA_YMAX - 1)
  124.  
  125. #define SVGA_VCHAR 24
  126. #define SVGA_HCHAR 8
  127. #define SVGA_VTIC 5
  128. #define SVGA_HTIC 5
  129.  
  130. #define SSVGA_XMAX 1024
  131. #define SSVGA_YMAX 768
  132.  
  133. #define SSVGA_XLAST (SSVGA_XMAX - 1)
  134. #define SSVGA_YLAST (SSVGA_YMAX - 1)
  135.  
  136. #define SSVGA_VCHAR 24
  137. #define SSVGA_HCHAR 8
  138. #define SSVGA_VTIC 5
  139. #define SSVGA_HTIC 5
  140.  
  141. #endif /* TERM_PROTO */
  142.  
  143. #ifndef TERM_PROTO_ONLY
  144. #ifdef TERM_BODY
  145.  
  146. void pause __P((void));
  147.  
  148. #include <fg.h>
  149.  
  150. static int pattern[] = {0xffff, 0x0f0f, 0xffff, 0xaaaa, 0x3333, 0x3f3f, 0x0f0f};
  151.  
  152. static int graphics_on = FALSE;
  153. int startx, starty;
  154. /*
  155. int pc_angle;
  156. #define PC_VCHAR FNT5X9_VCHAR
  157. #define PC_HCHAR FNT5X9_HCHAR
  158. */
  159. void pause()        /* press any key to continue... */
  160. {
  161.     (void) getch();
  162. }
  163.  
  164.  
  165. TERM_PUBLIC void PC_text()
  166. {
  167.     if (graphics_on) {
  168.         graphics_on = FALSE;
  169.         pause();
  170.     }
  171.    fg_term();
  172. }
  173.  
  174. TERM_PUBLIC void PC_reset()
  175. {
  176. }
  177.  
  178.  
  179.  
  180. /* all of the FlashGraphics C routines for the different graphics devices go here */
  181.  
  182.  
  183.  
  184. static int vga256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  185. static int *vgacolor = vga256color;
  186. static fg_color_t vga_color;
  187. static int text_angle;
  188. static fg_line_t line_to_draw;
  189.  
  190. TERM_PUBLIC int VGA_text_angle(ang)
  191. int ang;
  192. {
  193.     text_angle = ang;
  194.     return TRUE;
  195. }
  196.  
  197. TERM_PUBLIC int VGA_justify_text(mode)
  198. enum JUSTIFY mode;
  199. {
  200.     return FALSE;
  201. }
  202.  
  203. TERM_PUBLIC void VGA_init()
  204. {
  205.        if (fg_init() == FG_NULL)  {
  206.            fprintf(stderr,"Graphics card not detected.\n");
  207.            exit(1);
  208.       }
  209. }
  210.  
  211. TERM_PUBLIC void HERC_graphics()
  212. {
  213.    fg_init_herc();
  214.    graphics_on = TRUE;
  215. }
  216.  
  217. TERM_PUBLIC void EGAMONO_graphics()
  218. {
  219.    fg_init_egamono();
  220.    graphics_on = TRUE;
  221. }
  222.  
  223. TERM_PUBLIC void EGA_graphics()
  224. {
  225.    fg_init_egaecd();
  226.    graphics_on = TRUE;
  227. }
  228.  
  229. TERM_PUBLIC void VGA_graphics()
  230. {
  231.    fg_init_vga12();
  232.    graphics_on = TRUE;
  233. }
  234.  
  235. TERM_PUBLIC void VGAMONO_graphics()
  236. {
  237.    fg_init_vga11();
  238.    graphics_on = TRUE;
  239. }
  240.  
  241. TERM_PUBLIC void SVGA_graphics()
  242. {
  243.    fg_init_vesa6a();
  244.    graphics_on = TRUE;
  245. }
  246.  
  247. TERM_PUBLIC void SSVGA_graphics()
  248. {
  249.    fg_init_vesa5();
  250.    graphics_on = TRUE;
  251. }
  252.  
  253. TERM_PUBLIC void VGA_linetype(linetype)
  254. {
  255.    if (linetype >= 13)
  256.        linetype %= 13;
  257.        vga_color = fg.color[vgacolor[linetype+2]];
  258. }
  259.  
  260. TERM_PUBLIC void VGA_put_text(x,y,str)
  261. unsigned int x, y;
  262. char *str;
  263. {
  264.    fg_puts(vga_color, FG_MODE_SET,    ~0,  text_angle, x, y, str, fg.displaybox);
  265. }
  266.  
  267. TERM_PUBLIC void VGA_move(x,y)
  268. {
  269.      line_to_draw[FG_X1] = x;
  270.      line_to_draw[FG_Y1] = y;
  271. }
  272.  
  273.  
  274. TERM_PUBLIC void VGA_vector(x,y)
  275. {
  276.      line_to_draw[FG_X2] = x;
  277.      line_to_draw[FG_Y2] = y;
  278.      fg_drawline(vga_color, FG_MODE_SET, ~0, FG_LINE_SOLID, line_to_draw);
  279.      line_to_draw[FG_X1] = x;
  280.      line_to_draw[FG_Y1] = y;
  281. }
  282.  
  283. TERM_PUBLIC void VGA_text()
  284. {
  285.     if (graphics_on) {
  286.         graphics_on = FALSE;
  287.         fg_flush();
  288.         pause();
  289.     }
  290.    fg_term();
  291. }
  292.  
  293. TERM_PUBLIC void VGA_reset()
  294. {
  295.    fg_term();
  296. }
  297.  
  298. #endif /* TERM_BODY */
  299.  
  300. #ifdef TERM_TABLE
  301.  
  302. TERM_TABLE_START(hercules_driver)
  303.     "hercules", "IBM PC/Clone with Hercules graphics board",
  304.        HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
  305.        HERC_VTIC, HERC_HTIC, options_null, VGA_init, VGA_reset,
  306.        VGA_text, null_scale, HERC_graphics, VGA_move, VGA_vector,
  307.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  308.        VGA_justify_text, do_point, do_arrow, set_font_null
  309. TERM_TABLE_END(hercules_driver)
  310.  
  311. #undef LAST_TERM
  312. #define LAST_TERM hercules_driver
  313.  
  314. TERM_TABLE_START(egamono_driver)
  315.     "egamono", "IBM PC/Clone with monochrome EGA graphics board",
  316.        EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR,
  317.        EGA_VTIC, EGA_HTIC, options_null, VGA_init, VGA_reset,
  318.        VGA_text, null_scale, EGAMONO_graphics, VGA_move, VGA_vector,
  319.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  320.        VGA_justify_text, do_point, do_arrow, set_font_null
  321. TERM_TABLE_END(egamono_driver)
  322.  
  323. #undef LAST_TERM
  324. #define LAST_TERM egamono_driver
  325.  
  326. TERM_TABLE_START(egalib_driver)
  327.     "egalib", "IBM PC/Clone with color EGA graphics board",
  328.        EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR,
  329.        EGA_VTIC, EGA_HTIC, options_null, VGA_init, VGA_reset,
  330.        VGA_text, null_scale, EGA_graphics, VGA_move, VGA_vector,
  331.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  332.        VGA_justify_text, do_point, do_arrow, set_font_null
  333. TERM_TABLE_END(egalib_driver)
  334.  
  335. #undef LAST_TERM
  336. #define LAST_TERM egalib_driver
  337.  
  338. TERM_TABLE_START(vgalib_driver)
  339.     "vgalib", "IBM PC/Clone with VGA graphics board",
  340.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  341.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  342.        VGA_text, null_scale, VGA_graphics, VGA_move, VGA_vector,
  343.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  344.        VGA_justify_text, do_point, do_arrow, set_font_null
  345. TERM_TABLE_END(vgalib_driver)
  346.  
  347. #undef LAST_TERM
  348. #define LAST_TERM vgalib_driver
  349.  
  350. TERM_TABLE_START(vgamono_driver)
  351.     "vgamono", "IBM PC/Clone with monochrome VGA graphics board",
  352.        VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  353.        VGA_VTIC, VGA_HTIC, options_null, VGA_init, VGA_reset,
  354.        VGA_text, null_scale, VGAMONO_graphics, VGA_move, VGA_vector,
  355.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  356.        VGA_justify_text, do_point, do_arrow, set_font_null
  357. TERM_TABLE_END(vgamono_driver)
  358.  
  359. #undef LAST_TERM
  360. #define LAST_TERM vgamono_driver
  361.  
  362. TERM_TABLE_START(svgalib_driver)
  363.     "svgalib", "IBM PC/Clone with VESA Super VGA graphics board",
  364.        SVGA_XMAX, SVGA_YMAX, SVGA_VCHAR, SVGA_HCHAR,
  365.        SVGA_VTIC, SVGA_HTIC, options_null, VGA_init, VGA_reset,
  366.        VGA_text, null_scale, SVGA_graphics, VGA_move, VGA_vector,
  367.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  368.        VGA_justify_text, do_point, do_arrow, set_font_null
  369. TERM_TABLE_END(svgalib_driver)
  370.  
  371. #undef LAST_TERM
  372. #define LAST_TERM svgalib_driver
  373.  
  374. TERM_TABLE_START(ssvgalib_driver)
  375.     "ssvgalib", "IBM PC/Clone with VESA 256 color 1024 by 768 super VGA",
  376.        SSVGA_XMAX, SSVGA_YMAX, SSVGA_VCHAR, SSVGA_HCHAR,
  377.        SSVGA_VTIC, SSVGA_HTIC, options_null, VGA_init, VGA_reset,
  378.        VGA_text, null_scale, SSVGA_graphics, VGA_move, VGA_vector,
  379.        VGA_linetype, VGA_put_text, VGA_text_angle, 
  380.        VGA_justify_text, do_point, do_arrow, set_font_null
  381. TERM_TABLE_END(ssvgalib_driver)
  382.  
  383. #undef LAST_TERM
  384. #define LAST_TERM ssvgalib_driver
  385.  
  386. #endif /* TERM_TABLE */
  387. #endif /* TERM_PROTO_ONLY */
  388.  
  389. /*
  390.  * NAMES: hercules, egalib, egamono, vgalib, vgamono, svgalib, ssvgalib
  391.  *
  392.  * OPTIONS: none
  393.  *
  394.  * SUPPORTS: PC with arbitrary graphics board (autodetected)
  395.  *
  396.  * Further Info: Only used when compiled with Zortech C/C++.
  397.  *
  398.  */
  399.  
  400.